package com.hopu.v1.pojo.system;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hopu.v1.pojo.common.Save;
import com.hopu.v1.pojo.common.Update;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author YwaiX
 * @since 2024-09-12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("s_menu")
public class Menu implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "id不能为空", groups = Update.class)
    private Integer id;

    /**
     * 父级菜单id
     */
    @TableField("pid")
    @NotNull(message = "父级菜单id不能为空", groups = Update.class)
    private Integer pid;

    /**
     * 菜单名称
     */
    @Length(message = "菜单名不低于2位", min = 2, groups = Save.class)
    @NotBlank(message = "菜单名称不能为空",groups = {Save.class, Update.class})
    @TableField("menu_name")
    private String menuName;

    /**
     * 菜单描述
     */
    @TableField("menu_desc")
    @NotBlank(message = "菜单描述不能为空",groups = Update.class)
    private String menuDesc;

    /**
     * 菜单图标
     */
    @TableField("icon")
    @NotBlank(message = "菜单图标不能为空", groups = {Save.class, Update.class})
    private String icon;

    /**
     * 菜单跳转url
     */
    @TableField("url")
    @NotBlank(message = "菜单跳转url不能为空",groups = Update.class)
    private String url;

    /**
     * 排序
     */
    @TableField("sort_order")
    @NotNull(message = "排序不能为空", groups = {Save.class, Update.class})
    private Integer sortOrder;

    /**
     * 权限标识符
     */
    @TableField("permission_code")
    @NotBlank(message = "权限标识符不能为空",groups = {Save.class, Update.class})
    private String permissionCode;

    /**
     * 创建人
     */
    @TableField("create_by")
    private Integer createBy;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime createTime;

    /**
     * 修改人
     */
    @TableField("update_by")
    private Integer updateBy;

    /**
     * 修改时间
     */
    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime updateTime;

    /**
     * 状态，1启用；0禁用
     */
    @TableField("status")
    private Integer status;

    @TableField(exist = false)
    private List<Menu> children;

}
